<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>消息管理</el-breadcrumb-item>
      <el-breadcrumb-item>审批消息设置</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入收货人"  v-model="queryInfo.username" >
            <el-button slot="append" icon="el-icon-search" @click="getList"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table stripe :data="List" style="width: 100%">
        <el-table-column prop="id" type="index" label="ID" width="50"></el-table-column>
        <el-table-column prop="user" label="申请者" width="180"></el-table-column>
        <el-table-column prop="reason" label="审批原因"></el-table-column>
        <el-table-column prop="ctime" label="申请日期"></el-table-column>
        <el-table-column prop="state" label="审批状态"></el-table-column>
        <el-table-column label="操作" fixed="right" width="120">
          <template slot-scope="scope">
            <el-button  @click="openEditUser(scope.row)" type="text" size="mini" icon="el-icon-edit">编辑
            </el-button>
            <el-button type="text" size="mini" icon="el-icon-delete" @click="del(scope.row.id)">删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                     :current-page="queryInfo.page"
                     :page-sizes="[5, 10, 15, 30]"
                     :page-size="queryInfo.size"
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="total">
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Approve',
  mounted () {
    this.getList()
  },
  methods: {
    async getList () {
      const { data: res } = await this.$http.get('approval', { params: this.queryInfo })
      if (res.code !== 200) {
        return this.$message.error(res.msg)
      }
      this.List = res.data.data
      this.total = res.data.total
    },
    handleSizeChange (val) {
      this.queryInfo.size = val
      this.getList()
    },
    handleCurrentChange (val) {
      this.queryInfo.page = val
      this.getList()
    }
  },
  data () {
    return {
      rulesAdd: { state: [{ required: true, message: '请输入签收状态', trigger: 'blur' }] },
      total: 0,
      queryInfo: { username: '', page: 1, size: 10 },
      List: [],
      editForm: {},
      editDialogVisible: false
    }
  }
}
</script>

<style scoped>

</style>
